package com.zklh.book.system.view.render;

import com.zklh.book.system.view.OperationOption;
import com.zklh.book.system.view.ViewRenderer;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

/**
 * 主页视图
 *
 * @author 坐看落花
 * @version 1.0
 * @date 2021/3/21 9:45
 */
public class HomeViewRenderer implements ViewRenderer {

    /**
     * 需要参数 username 用户名
     * @param params
     */
    public void render(Map<String, Object> params) {
        System.out.println("登录成功,欢迎您!" + params.get("username"));
        System.out.println("****************************************************************");
        System.out.println("*                                                              *");
        System.out.println("*                      图 书 管 理 系 统                         *");
        System.out.println("*                                                              *");
        System.out.println("****************************************************************");
    }


    public static void main(String[] args) {
        HomeViewRenderer view = new HomeViewRenderer();
        Map<String,Object> params =  new HashMap<>();
        params.put("username","童楠");
        params.put("role","consumer");
        params.put("operations", Arrays.asList(
           new OperationOption(1,"借书", Arrays.asList("consumer")),
           new OperationOption(2,"还书", Arrays.asList("consumer")),
           new OperationOption(3,"新增图书", Arrays.asList("consumer")),
           new OperationOption(4,"我的图书", Arrays.asList("admin")),
           new OperationOption(5,"新增图书", Arrays.asList("admin")),
           new OperationOption(6,"删除图书", Arrays.asList("admin")),
           new OperationOption(7,"查看图书", Arrays.asList("admin", "consumer"))
        ));
        view.render(params);
    }
}
